import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

/** Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/build-overview',
    component: Layout,
    children: [
      {
        path: '/build-overview',
        name: 'BuildOverview',
        component: () => import('@/views/build-overview/index'),
        meta: { title: 'BuildOverview', icon: 'form' }
      }
    ]
  },
  { path: '*', redirect: '/build-overview', hidden: true }
]

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
